<template>
	<view class="container">
		<u-navbar :autoBack="true" :title-bold='true' title='我拓展的好友' :border-bottom='false'> </u-navbar>

		<view class="_img">
			己所欲，则广施于人!
		</view>

		<block v-for="(item,index) in list" :key="index">
			<navigator class="card" :url="index==2?'/sub/center/mine/tuozanlist':''">
				<view class="left">
					<p>{{item.title}}</p>
					<p>{{item.el}}</p>
					<text>{{item.label}}</text>
				</view>
				<view class="right">
					{{item.num}}人
					<uni-icons v-if="index==2" type="right" size='15'></uni-icons>
				</view>
			</navigator>

		</block>

		<view class="_img">
			知识不是力量，知识传播出去，
			<p>用于实践，用之于民，才是力量。</p>
			<p>生活中的便利，分享给好友，这是我的责任!</p>
		</view>
		<view class="btu btn">
			<button open-type="share"> 立即分享</button>
		</view>
		<p class="dsc">转发让好友注册登录，获得晴空万里券￥10</p>

	</view>
</template>

<script>
	import {
		expandedFriends,
		addCoupon
	} from '@/api/index.js'
	export default {
		data() {
			return {
				list: [{
						title: '联系人总人数',
						num: 0
					},
					{
						title: '我拓展的普通朋友',
						num: 0,
						label: ''
					},
					{
						title: '我拓展的专业人士',
						num: 0,
						label: ''
					},
					{
						title: '我拓展的好友',
						num: 0,
						label: '',
						el: '他又拓展了专业人士'
					},
				],
				user: ''
			}
		},
		onLoad() {
			this.user = this.ws.getUserInfo()
			this.init()
		},

		methods: {
			init() {
				expandedFriends().then(res => {
					// total总数  ordinary普通 doctor专业人士  moredoctor
					if (res.code == 1) {
						this.list[0].num = res.data.total
						this.list[1].num = res.data.ordinary
						this.list[2].num = res.data.doctor
						this.list[3].num = res.data.moredoctor

						if (this.user.job == 1) {
							this.list[1].label = '我获得' + res.data.total + '份晴空万里在线聊天券'
						}
						this.list[2].label = res.data.tips
						this.list[3].label = res.data.tips2

						this.$store.state.tuozanlist = res.data.shareList
					}
				})
			},
			share() {
				addCoupon().then(res => {
					console.log(res, '获得优惠券');
				})
			}
		}
	}
</script>

<style lang="scss">
	.container {
		height: 100vh;
		background-color: #FFF;
		padding: 30rpx 0;


		._img {
			margin: 30rpx;
			background: #F9F9F9;
			border-radius: 11px;
			color: #999999;
			padding: 30rpx 20rpx;
		}

		.btu {
			margin-top: 20px;
			background-color: #6EC9E1;
			height: 50px;

			button {
				width: 100%;
				height: 100%;
				display: flex;
				justify-content: center;
				align-items: center;
				background-color: unset;
				border: unset;
				color: #FFF;
				padding-left: 50rpx;
				line-height: unset;

				view {
					font-size: 14px;
					text-align: left;
				}
			}

		}

		.dsc {
			text-align: center;
			margin-top: 10rpx;
			color: #999999;
			font-size: 12px;
		}

		.card {
			padding: 20rpx 30rpx;
			min-height: 60px;
			display: flex;
			align-items: center;
			justify-content: space-between;
			font-family: PingFang SC;
			border-bottom: 0.5rpx solid rgba(190, 190, 190, 0.2);

			p,
			text {
				line-height: 25px;
			}

			image {
				height: 50px;
				width: 50px;
				border-radius: 50%;
			}

			.right {
				display: flex;
				justify-content: flex-end;
				align-items: center;
				min-width: 20vw;

			}

			text {
				font-size: 13px;
				color: #999999;
			}
		}

	}
</style>